﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MineCraft_Command_Editor.FileSystemIO
{
    class GetFile
    {

        internal static List<string> nodeFiles = new List<string>();

        public static List<string> ListFiles(FileSystemInfo info)
        {
            if (!info.Exists) { return null; };

            DirectoryInfo dir = info as DirectoryInfo;
            //不是目录 
            if (dir == null) { return null; };

            FileSystemInfo[] files = dir.GetFileSystemInfos();
            for (int i = 0; i < files.Length; i++)
            {
                FileInfo file = files[i] as FileInfo;
                //是文件 
                if (file != null)
                {
                    nodeFiles.Add(file.FullName);
                }
                //对于子目录，进行递归调用 
                else
                {
                    ListFiles(files[i]);
                }
            }
            return nodeFiles;
        }
    }
}
